#ifndef CNC_BASE_DATABASE_H
#define CNC_BASE_DATABASE_H

#include "db_.h"
// provided interfaces
//	#include "persistentdata.h"
// basic component model
#include <bcm/bcm.h>

namespace cnc {

	namespace base {

		/**
		@brief Parameter database component.
		
		This class implements a generic parameter database component.
		*/

		class Database : public bcm::Identifier<bcm::Component>,
			public DatabaseImpl
		{
		protected:
			Database() : bcm::Identifier<bcm::Component>("db", "Database")
			{
			}
		protected: // bcm::Component
			virtual bcm::IdentifierData *getProvidedInterfaceTable()
			{
				static bcm::IdentifierData idData[] = {
					{ "pdata", "Permanent Data" },
					{ 0, 0 }
				};
				return idData;
			}
			virtual bcm::IdentifierData *getRequiredInterfaceTable()
			{
				static bcm::IdentifierData idData[] = {
					{ 0, 0 }
				};
				return idData;
			}
			virtual bcm::Interface *getInterface(const char *id)
			{
				if (std::string("pdata") == id)
					return getPersistentData();
				return 0;
			}
			virtual bool setInterface(bcm::Interface *iface)
			{
				return false;
			}
		public:
			static Database &instance()
			{
				static Database object;
				return object;
			}
		};

	} // namespace base

} // namespace cnc

#endif

